package com.cucn.ingmall.member.web;

import com.alibaba.fastjson.JSON;
import com.cucn.common.utils.R;
import com.cucn.ingmall.member.feign.OrderFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 用户服务web
 *
 * @author KouChaoJie
 * @since: 2022/1/28 16:20
 */
@Controller
@Slf4j
public class MemberWebController {
    @Resource
    private OrderFeignService orderFeignService;

    @GetMapping("/memberOrder.html")
    public String memberOrderPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, Model model) {
        //获取到支付宝给我们传来的请求参数
        //request:验证签名,如果正确可以修改订单列表



        //查出当前登录的用户所有订单列表数据
        Map<String, Object> pageParams = new HashMap<>();
        pageParams.put("page", pageNum.toString());
        //远程调用查询已登录用户的所有订单数据
        R r = orderFeignService.listWithItem(pageParams);

        log.info(JSON.toJSONString(r));

        model.addAttribute("orders", r);
        return "orderList";
    }
}
